<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 14-10-29
 * Time: 下午2:11
 */
header('Content-type=text/html;charset=utf-8');
if($_POST['path']){
    $path_start = $_POST['path'];
    $path = opendir($path_start);
    //TODO 是否应该执行循环输出下级文件夹目录
?>
    <p>目录信息如下</p>
    <table border="0" cellspacing="0" cellpadding="0"  width="450" align="center">
        <tr align="left" bgcolor="#cccccc">
            <th>文件名</th>
            <th>大小</th>
            <th>类型</th>
            <th>修改时间</th>
        </tr>
    <?php
        $str = '';
        while($files = readdir($path)){
            $dir = $path_start."/".$files;
            $str .= '<tr align="center" >';
            $str .= '<td>'.$files.'</td>';
            $str .= '<td>'.floor((filesize($dir))/1024).'kb</td>';
            $str .= '<td>'.(filetype($dir)=='dir'?'文件夹':'文件').'</td>';
            $str .= '<td>'.date("Y-m-d",filemtime($dir)).'</td>';
            $str .= '</tr>';
        }
    echo $str;
    ?>
</table>

<?php
}
?>